package org.sdau.rotten.library.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

@Configuration
public class ErrorConfig implements ErrorPageRegistrar {
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage[] errorPages = new ErrorPage[5];
        errorPages[0] = new ErrorPage(HttpStatus.NOT_FOUND,"/404Page");
        errorPages[1] = new ErrorPage(HttpStatus.BAD_REQUEST,"/404Page");
        errorPages[2] = new ErrorPage(HttpStatus.NOT_ACCEPTABLE,"/404Page");
        errorPages[3] = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/404Page");
        errorPages[4] = new ErrorPage(HttpStatus.METHOD_NOT_ALLOWED,"/404Page");
        registry.addErrorPages(errorPages);
    }
}
